<block name="header"></block>
<php>
//验证登录
    $uid = is_login();
if(!$uid){
   Cookie ( '__forward__', $_SERVER ['REQUEST_URI'] );
   redirect(U('home/user/login'));
}

if(isset($_GET['sidenav'])){
    $navClass[$_GET['sidenav']] = 'active';
}else{
    $m = strtolower(MODULE_NAME);
    $c = strtolower(CONTROLLER_NAME);
    $a = strtolower(ACTION_NAME);
    $navClass[$m] = $navClass[$m.'_'.$c] = $navClass[$m.'_'.$c.'_'.$a] = 'active';
    
    $ad = ucfirst ( parse_name ( $_REQUEST['_addons'], 1 ) );
    $cl = ucfirst ( parse_name ( $_REQUEST['_controller'], 1 ) );
    $navClass[$ad] = $navClass[$ad.'_'.$cl] = 'active';
}

    $rules_ids = M('ucenter_member_addons')->field('rules_ids')->where("ucenter_member_id=$uid")->find();
    $rules_arr = explode(',',$rules_ids['rules_ids']);
    $addonList = D ( 'Addons' )->getWeixinList (false, array(), true);

    $data = array();
    if($uid==1){
        $data = $addonList;
    }else{
        foreach($addonList as $v){
            if(in_array($v['id'],$rules_arr)){
                 $data[]=$v;
            }
        }
    }
$categorys = M ( 'addon_category' )->order ( 'sort asc, id desc' )->select ();
foreach($categorys as &$cate){
   foreach($data as $k=>$a){
      if($cate['id']==intval($a['cate_id'])){
           $cate['addons'][] = $a;
           unset($data[$k]);
      }
   }
}
</php>
<div id="main-container" class="container">
	<div class="sidebar">
    	<ul class="sidenav">
            <if condition="$uid eq 1">
          <li>
              <a class="sidenav_parent" href="javascript:;"><b class="ficon fa fa-plus-square"></b>帐号管理</a>
              <ul class="sidenav_sub" style="display:none">
                  <li class="{$navClass['home_memberpublic']}"> <a href="{:U('Home/MemberPublic/lists')}">公众号管理 </a> <b class="active_arrow"></b></li>
                  <li class="{$navClass['home_index_main']}"> <a href="{:U('Home/Index/main')}">插件管理 </a> <b class="active_arrow"></b></li>
                  <li class="{$navClass['home_creditconfig_lists']}"> <a href="{:U('Home/CreditConfig/lists')}">积分配置 </a> <b class="active_arrow"></b></li>
                  <li class="{$navClass['home_keyword']}"> <a href="{:U('Home/Keyword/lists')}">关键词维护 </a> <b class="active_arrow"></b></li>
                  <li class="{$navClass['home_cascade']}"> <a href="{:U('Home/Cascade/lists')}">级联数据管理 </a> <b class="active_arrow"></b></li>
             </ul>
          </li>
            </if>
          <volist name='categorys' id='ca'>
          <notempty name="ca.addons">
          <li>
              <a class="sidenav_parent" href="javascript:;"><b class="ficon fa fa-plus-square"></b>{$ca.title}</a>
              <ul class="sidenav_sub" style="display:none">
                  <volist name='ca.addons' id='vo'>
                      <li class="{$navClass[$vo[name]]}"> <a href="{$vo[addons_url]}" title="{$vo.description}"> 
                      <i class="icon-chevron-right"><php>if(!empty($vo['icon'])) { </php> <img src="{$vo.icon}" /> <php> } </php> </i>
                      {$vo.title} </a><b class="active_arrow"></b></li>
                  </volist>
             </ul>
          </li>
          </notempty>
          </volist>
          <notempty name="data">
          <li>
              <a class="sidenav_parent" href="javascript:;"><b class="ficon fa fa-plus-square "></b>其它功能</a>
              <ul class="sidenav_sub" style="display:none">
              <volist name='data' id='vo'>
              <li class="{$navClass[$vo[name]]}"> <a href="{$vo[addons_url]}" title="{$vo.description}"> 
              <i class="icon-chevron-right"><php>if(!empty($vo['icon'])) { </php> <img src="{$vo.icon}" /> <php> } </php> </i>
              {$vo.title} </a> </li>
              </volist>
              </ul>
          </li>
          </notempty>
        </ul>
  </div>
<div class="main_body">
	<block name="body"></block>
</div>
</div>